home *** CD-ROM | disk | FTP | other *** search
- Path: smis-sst-mg1-dip1-16.massey.ac.nz!user
- From: A.J.Norman@massey.ac.nz
- Newsgroups: comp.lang.c++
- Subject: Re: keypress
- Date: 22 Jan 1996 19:50:43 GMT
- Organization: Massey University
- Message-ID: <A.J.Norman-2301960852530001@smis-sst-mg1-dip1-16.massey.ac.nz>
- References: <4dm5fr$2pi@prometheus.algonet.se>
- NNTP-Posting-Host: smis-sst-mg1-dip1-16.massey.ac.nz
-
- In article <4dm5fr$2pi@prometheus.algonet.se>, Tkb@Algonet.Se (Johan
- Leikvik) wrote:
-
- > Hi, I'm a beginner in c++ and I have a little problem.. I wonder how
- > I read a key in a loop.. example: If I press the key 4 a variable
- > should increase.. But it shouldn't stop the program.. Please help me!
- >
- > Yours:
- >
- > Johan
-
- I would suggest something along the following lines
-
- while (!kbhit()&&(key==ReadKey())!=<quit key code)
- if (key==<code of key 4>)
- Variable++;
-
- This is written using BC3.1.
-
- Hope this gives you some ideas.
- Andrew
-
- --
- E-mail: A.J.Norman@massey.ac.nz
- "With the freedom of speech comes the freedom to be misunderstood"
- "When the going gets tough, the tough go on holiday"
- "Conserve ammo, watch your back and never deal with a dragon" - ShadowRunners comment on a blackened scorched wall.
-